@extends('layouts.admin')
@section('content')
    <div id="ribbon"><ol class="breadcrumb"><li>内容区</li></ol></div>
    <div class="content_wrapper">
        <aside>
            <header><i class="fa fa-fw fa-file"></i>订单列表</header>
            <section>
                <div class="row">
                    <div class="col-sm-12">
                        <form action="" method="get">
                            <div class="btn-group">
                                <select name="agent_id" class="form-control">
                                    <option value="">请选择公司</option>
                                    @foreach($agents as $k => $v)
                                        <option value="{{$k}}" {{request('agent_id') == $k ? 'selected' : ''}}>{{$v}}</option>
                                    @endforeach
                                </select>
                            </div>
                            <div class="btn-group">
                                <input type="text" class="form-control" placeholder="订单号" name="order_num" value="{{request('order_num')}}">
                            </div>
                            <div class="btn-group">
                                <input type="text" class="form-control" placeholder="用户手机号" name="mobile" value="{{request('mobile')}}">
                            </div>
                            <div class="btn-group">
                                <select name="pay_status" class="form-control">
                                    <option value="">请选择支付状态</option>
                                    @foreach(\App\Model\Order::$payStatusLabels as $k => $v)
                                        <option value="{{$k}}" {{isset($params['pay_status']) && $params['pay_status'] !== '' && $params['pay_status'] == $k ? 'selected' : ''}}>{{$v}}</option>
                                    @endforeach
                                </select>
                            </div>
                            <div class="btn-group">
                                <select name="status" class="form-control">
                                    <option value="">请选择订单状态</option>
                                    @foreach(\App\Model\Order::$statusLabels as $k => $v)
                                        <option value="{{$k}}" {{isset($params['status']) && $params['status'] !== '' && $params['status'] == $k ? 'selected' : ''}}>{{$v}}</option>
                                    @endforeach
                                </select>
                            </div>
                            <div class="btn-group">
                                <button class="btn btn-default"><i class="fa fa-filter"></i>查询</button>
                            </div>
                        </form>
                        <div class="table-responsive" style="margin-top:10px;">
                            <table id="example" class="table table-striped table-bordered table-hover" cellspacing="0"
                                   width="100%">
                                <thead>
                                <tr>
                                    <th>公司</th>
                                    <th>订单号</th>
                                    <th>用户昵称</th>
                                    <th>用户手机</th>
                                    <th>订单额</th>
                                    <th>支付状态</th>
                                    <th>订单状态</th>
                                    <th>创建时间</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                    @foreach($list as $value)
                                        <tr>
                                            <td>{{$agents[$value['agent_id']] or ''}}</td>
                                            <td>{{$value['order_num']}}</td>
                                            <td>{{$value['user']['nickname']}}</td>
                                            <td>{{$value['user']['username']}}</td>
                                            <td>{{$value['money']}}</td>
                                            <td>{{$value['pay_status'] == 1 ? '已支付' : '未支付'}}</td>
                                            <td>{{$statusLabels[$value['status']] or ''}}</td>
                                            <td>{{$value['created_at']}}</td>
                                            <td>
                                                <a href="{{url('admin/order/detail?order_id=' . $value['id'])}}" class="btn btn-success btn-xs">订单详情</a>
                                            </td>
                                        </tr>
                                    @endforeach
                                </tbody>
                            </table>
                        </div>
                        <nav>{!! $list->appends($params)->render() !!}</nav>
                    </div>
                </div>
            </section>
        </aside>
    </div>
@endsection